Content starts here Data Service Types and Functions
This page last changed on Mar 07, 2008.

eDocs Home > BEA AquaLogic Data Services Platform Documentation > Data Services Developer's Guide > Contents

Data Service Types and Functions

ALDSP functions can have a number of attributes. This section describes those attributes and the conditions under which they are applicable.

ALDSP Data Service Types and Attributes

Types and function attributes are mutually exclusive. For example, function access can be set to public, protected, or private. Similarly, a data service type can be logical or physical, not both. Other characteristics are simply inapplicable. For example, create-update-delete routines always operate as procedures, not functions.

Data Service Characteristics

The following table describes the characteristics of ALDSP data services. Data service characteristics are defined in the XQuery source pragma.

Data Service Characteristics
Characteristic Description
Type
There are two types of data services:
  • Physical. The data service is directly based on metadata imported from underlying data sources. Physical data services are created during the metadata import process.
  • Logical. The data service is based wholly or partially on data derived from other data services. Logical data services are created either through the Query Map Editor or in source.
Shape
The shape of a data service is determined by its XML type, or underlying schema, if any. Shapes are:
  • Entity. An entity data service is associated with an XML type. For example, physical data services based on relational tables are entity data services. For any given entity data service, all read functions return information in the shape of the primary XML type.
  • Library. A library data service is not associated with an XML type. Library data services contain routines that can be used by other library or entity data services.
Building XQueries

Operational Characteristics

The following table describes the characteristics that can be used to describe functional routines in ALDSP. These characteristic descriptions are also part of the function's signature, visible in data service Souce editor.

ALDSP Operations Characteristics
Characteristic Description
Access Access or visibility to a functional routine can be set as:
  • Public. A public operation can be called from:
    • any operation in the same data space and
    • from an ALDSP client API. Public operations are the only ones that can be called from client APIs such as Web services or the Java Mediator API.
  • Protected. An operation with protected visibility can be called from any operation in the same data space. Protected operations cannot be accessed from ALDSP client APIs. An operation in the data space can access the function. Functions in physical data services are, by default, protected.
  • Private. The function can only be accessed by other functions in its data service. Operations with private visibility are also off-limits to client APIs.
Primacy

Every logical entity data service identifies a single primary function for each kind of function. For example, if there are several read functions, one will be set as primary.

In the case of read functions, the data service relies on the primary read function in the data service to determine the shape of the Return type.

For create, update, and delete functions, the primacy setting is used by update templates of component data services.
In an entity data service, a function can be set as primary. Other functions of a similar type are automatically considered non-primary.
Library functions have no Return type and are not categorized as primary or non-primary.
Kind
ALDSP has several kinds of functions. For physical data services, the kind of function is inferred during the data service creation process, when metadata is imported.

Four of the functions are actually CRUD (create-read-update-delete) procedures, which operate on the underlying data.  
  • Read. Returns data from an underlying data source.
  • Create. Creates one or several records.
  • Update. Updates one or several records.
  • Delete. Deletes one or several records.
    Other kinds of functions include:
  • Navigate. Navigate function have the current data service Return type as one of the input parameters; it typically returns a sequence of the return schema element from the related data Service. Example: Return type Order instead of Return type Customer.
  • Library. Functions, which are independent of the data service XML type. Library functions can appear in either data services and library data services
Operation
There are two types of operations:
  • Functional. General-purpose data service functions are designed to retrieve data for clients. Functions cannot have side-effects. Functions can be defined through XQuery or XQSE. If XQSE is used, the fact that the routine is identified as a function means that it does not have side effects.
  • Procedural. The purpose of a procedural function (also called a procedure or side-effecting procedure) is to affect external processes. A classic example of a side-effecting procedure is an RDBMS stored procedure that modifies underlying data. When a stored procedure is invoked, it operates on the data in the RDBMS without necessarily returning anything to the caller. Similarly, in ALDSP, a procedural function will primarily invoke an external process. Create-update-delete operations are, by definition, procedural.
    Note: There is an important distinction between functions and procedures from the perspective of the data service optimizing engine. Procedures are always considered to have side-effects and are therefore never optimized by the XQuery engine in such a way that they do not independently execute. While a delete() function might not be executed (i.e., "optimized away"), a delete() procedure will always be called.
    Functions with and Without Side Effects (click to see full size)

Green boxes represent functions without side effects; red boxes represent functions that may have side effects; boxes with both colors represent functions which can optionally contain side-effects. |

Implementation
Functions can be implemented in the following ways:
  • XQuery. The most common means of implementing an ALDSP function is through XQuery. Of course the data service itself is implemented in XQuery.
  • XQSE. The XQuery Scripting Extension provides a procedural language to extend XQuery to support certain kinds of operations.
  • Template-based. An update template defines the data flow and order for update operations for a logical data service. The update engine in the ALDSP server executes a procedure based on a template; is typically a Java routine used to manage updates of non-relational data. The same template is used by create, update, and delete routines.
  • External. External functions are based on physical sources such as Java, web services, XML, flat files, or relational sources. External functions can be created in entity or library data services.
Document generated by Confluence on Apr 28, 2008 15:57